// reducer就是一个函数，并且是纯函数,用于给store计算出新的state
// 接受一个state action作为一个参数，并且返回一个新的state

// 初始状态
// let initialState = ['学react','学vue3','学redux']
let initialState = 20
const rootReducer = (state = initialState,action) => {
    // return [...state] //返回新的状态
    
    let {type,payload} = action
    // console.log(action);
    switch (type) {
        // 自增
        case 'INCREASE_COUNT':
            return state + payload
        case 'DECREASE_COUNT':
            return state - payload
        default:
            return state
    } 
    
}
export default rootReducer